<?php
namespace app\modules\cn\models;
use yii\db\ActiveRecord;
use app\libs\Pager;
use app\modules\cn\models\Content;
class ResourcesPhone extends ActiveRecord {
    public $cateData;

    public static function tableName(){
            return '{{%resources_phone}}';
    }

    /**
     * 保存电话
     * @Author: Ferre
     * @create: 2021/3/15 14:24
     * @param $posts
     */
    public static function savePhone($posts)
    {
//        $tmp = self::find()->asArray()->where(['uid' => $posts['uid']])->one();
//        if (!empty($tmp)) return 2;
        $model = new self();
        $model->uid = @$posts['uid'];
        $model->phone = $posts['phone'];
        $model->createTime = time();
        $model->remark = isset($post['remark'])?$post['remark']:'';
        $model->save();
        return 1;
    }

    /**
     * [checkResource 判断是否报名]
     * @Author don
     * @Date   2021-12-15
     * @param  [type]     $uid    [description]
     * @param  [type]     $remark [description]
     * @return [type]             [description]
     */
    public static function checkResource($uid, $remark)
    {
        $tmp = self::find()->where(['uid'=>$uid, 'remark'=>$remark])->one();
        if (!empty($tmp)) {
            return true;
        }
        return false;
    }
}
